import api from './index'
import axios from 'axios'
import Vue from "vue";
import {TOKEN,NAME} from "@/store/mutations";



export function getNode () {
    return axios({
        url: api.Node,
        method: 'get',
    })
}
export function getClient () {
    return axios({
        url: api.ReadClient+Vue.ls.get(NAME,''),
        method: 'get',
    })
}
export function deleteClient (clientid) {
    return axios({
        url: api.deleteClient+clientid,
        method: 'delete',
    })
}

export function createClient (parameter) {
    return axios({
        url: api.Client,
        method: 'post',
        data:parameter,
        headers:{
            'Authorization':'JWT '+Vue.ls.get(TOKEN,'')
        }
    })
}


export function getNodeClientInfo (parameter) {
    return axios({
        url: api.clientinfo+parameter,
        method: 'get',
    })
}

export function getClientLocation (parameter) {
    return axios({
        url: api.location+parameter+'&coor=bd09ll',
        method: 'get',
    })
}

export function getlastdata (parameter) {
    return axios({
        url: api.GetLastdata+parameter,
        method: 'get',

    })
}

export function subscribe (parameter) {
    return axios({
        url: api.Subscribe,
        method: 'post',
        data:parameter,
    })
}

export function unsubscribe (parameter) {
    return axios({
        url: api.Unsubscribe,
        method: 'post',
        data:parameter,
    })
}

export function publish (parameter) {
    return axios({
        url: api.Publish,
        method: 'post',
        data:parameter,
    })
}

export function getdata (parameter) {
    return axios({
        url: api.Getdata+parameter,
        method: 'get',
    })
}


export  function getSubscriptions (parameter) {
    return axios({
        url: api.Subscriptions+parameter,
        method: 'get',
    })

}

export  function getSubLog () {
    return axios({
        url: api.SubLog+Vue.ls.get(NAME,''),
        method: 'get',
    })

}

export  function getClientLog () {
    return axios({
        url: api.ClientLog+Vue.ls.get(NAME,''),
        method: 'get',
    })

}
export function getcount () {
    return axios({
        url: api.getcount+Vue.ls.get(NAME,''),
        method: 'get',
    })
}
export function createApp (parameter) {
    return axios({
        url: api.create,
        method: 'post',
        data:parameter,
        headers:{
            'Authorization':'JWT '+Vue.ls.get(TOKEN,'')
        }
    })
}
export function getApp () {
    return axios({
        url: api.getApp+Vue.ls.get(NAME,''),
        method: 'get',
    })
}